package com.tea.funct.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tea.common.annotation.Log;
import com.tea.common.core.controller.BaseController;
import com.tea.common.core.domain.AjaxResult;
import com.tea.common.enums.BusinessType;
import com.tea.funct.domain.TeaAdvertisConfig;
import com.tea.funct.service.ITeaAdvertisConfigService;
import com.tea.common.utils.poi.ExcelUtil;
import com.tea.common.core.page.TableDataInfo;

/**
 * 广告限时体验配置Controller
 * 
 * @author Sophia
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/funct/config")
public class TeaAdvertisConfigController extends BaseController
{
    @Autowired
    private ITeaAdvertisConfigService teaAdvertisConfigService;

    /**
     * 查询广告限时体验配置列表
     */
    @PreAuthorize("@ss.hasPermi('funct:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeaAdvertisConfig teaAdvertisConfig)
    {
        startPage();
        List<TeaAdvertisConfig> list = teaAdvertisConfigService.selectTeaAdvertisConfigList(teaAdvertisConfig);
        return getDataTable(list);
    }

    /**
     * 导出广告限时体验配置列表
     */
    @PreAuthorize("@ss.hasPermi('funct:config:export')")
    @Log(title = "广告限时体验配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeaAdvertisConfig teaAdvertisConfig)
    {
        List<TeaAdvertisConfig> list = teaAdvertisConfigService.selectTeaAdvertisConfigList(teaAdvertisConfig);
        ExcelUtil<TeaAdvertisConfig> util = new ExcelUtil<TeaAdvertisConfig>(TeaAdvertisConfig.class);
        util.exportExcel(response, list, "广告限时体验配置数据");
    }

    /**
     * 获取广告限时体验配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('funct:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teaAdvertisConfigService.selectTeaAdvertisConfigById(id));
    }

    /**
     * 新增广告限时体验配置
     */
    @PreAuthorize("@ss.hasPermi('funct:config:add')")
    @Log(title = "广告限时体验配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeaAdvertisConfig teaAdvertisConfig)
    {
        return toAjax(teaAdvertisConfigService.insertTeaAdvertisConfig(teaAdvertisConfig));
    }

    /**
     * 修改广告限时体验配置
     */
    @PreAuthorize("@ss.hasPermi('funct:config:edit')")
    @Log(title = "广告限时体验配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeaAdvertisConfig teaAdvertisConfig)
    {
        return toAjax(teaAdvertisConfigService.updateTeaAdvertisConfig(teaAdvertisConfig));
    }

    /**
     * 删除广告限时体验配置
     */
    @PreAuthorize("@ss.hasPermi('funct:config:remove')")
    @Log(title = "广告限时体验配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teaAdvertisConfigService.deleteTeaAdvertisConfigByIds(ids));
    }
}
